const { chineseReg } = require("./contants");
const crypto = require('crypto')
const t = require('@babel/types')
function haveChineseChart(value) {
  return chineseReg.test(value);
}

function createHashCode(value,filePath){
  const data = value + '|' + filePath;
  const hash = crypto.createHash('shake256', { outputLength: 3 }).update(data).digest('hex');

 return '_'+hash
}

const ignoreFun={
  // StringLiteral  描述内需要忽略转义的
  isConsole(path){
    // 如果被console.log包裹，不转义
    // console.log('path.parent.callee.object',path.parent)
    if(t.isCallExpression(path.parent) && !t.isIdentifier(path.parent.callee)){
      
      const name = path.parent.callee.object.name;
      if(name === 'console'){
        return true;
      }
    }

  }
}


module.exports = {
  haveChineseChart,
  createHashCode,
  ignoreFun
};
